#pragma once
#include "SList.h"

void SLTest01()
{
	SListNode* node1 = (SListNode*)malloc(sizeof(SListNode));
	SListNode* node2 = (SListNode*)malloc(sizeof(SListNode));
	SListNode* node3 = (SListNode*)malloc(sizeof(SListNode));
	SListNode* node4 = (SListNode*)malloc(sizeof(SListNode));
	
	node1->val = 1;
	node2->val = 2;
	node3->val = 3;
	node4->val = 4;

	node1->next = node2;
	node2->next = node3;
	node3->next = node4;
	node4->next = NULL;

	SLPrint(node1);
}

void SLTest02()
{
	SListNode* node = NULL;
	SLPushBack(&node, 1);
	SLPushBack(&node, 2);
	SLPushBack(&node, 3);
	SLPrint(node);
}

void SLTest03()
{
	SListNode* node = NULL;
	SLPushFront(&node, 1);
	SLPushFront(&node, 2);
	SLPushFront(&node, 3);
	SLPrint(node);
}

void SLTest04()
{
	SListNode* plist = NULL;
	SLPushBack(&plist, 1);
	SLPushBack(&plist, 2);
	SLPushBack(&plist, 3);
	SLPushBack(&plist, 4);
	/*SLPopBack(&plist);
	SLPopBack(&plist);*/
	SLPopFront(&plist);
	SLPopFront(&plist);
	SLPopFront(&plist);
	SLPopFront(&plist);
	SLPrint(plist);
}

void SLTest05()
{
	SListNode* plist = NULL;
	SLPushBack(&plist, 1);
	SLPushBack(&plist, 2);
	SLPushBack(&plist, 3);
	SListNode* cur = SLFind(plist, 2);
	if (cur != NULL)
	{
		SLInsert(&plist, cur, 20);
	}
	cur = SLFind(plist, 3);
	if (cur != NULL)
	{
		SLInsert(&plist, cur, 30);
	}
	cur = SLFind(plist, 2);
	if (cur != NULL)
	{
		SLErase(&plist, cur);
	}
	cur = SLFind(plist, 30);
	if (cur != NULL)
	{
		SLErase(&plist, cur);
	}
	SLPrint(plist);
}

void SLTest07()
{
	SListNode* plist = NULL;
	SLPushBack(&plist, 1);
	SLPushBack(&plist, 2);
	SLPushBack(&plist, 3);
	SLPushBack(&plist, 4);
	SListNode* cur = SLFind(plist, 2);
	if (cur != NULL)
	{
		SLEraseAfter(cur);
	}

	SLPrint(plist);
	SLDestroy(plist);
}
int main()
{
	SLTest07();
	return 0;
}